<?php
/**
 * 描述：杂志期刊-DM杂志。
 * @final
 */
final class Exec_Magazine_Dm_List extends Exec
{
    /**
     * 描述：杂志列表。
     * @access public
     */
    public function Get()
    {
        #获取数据
        $data=DB::GetData('select * from dm order by ID desc limit ?,6');
        if($data)
        {
            foreach($data['Record'] as $key=>&$row)
            {
                $row['Summary']=explode(',',$row['Summary']);
                $row['CoverLocation']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['CoverLocation'];
            }
        }
        
        #渲染输出
        View::Assign('Magazine_List_DM',$data['Record']);
        View::Assign('Magazine_List_PageMenu',PagerFactory::Create('Common')->Fetch($data,array
        (
            'URL'=>'/exec.php?action=magazine_dm_list',
            'IsDetail'=>TRUE,
            'Rewriter'=>new PagerRewrite('/dm/','type','html')
        )));
        View::Display('magazine/dm/list.tpl');
    }

    /**
     * 描述：杂志订阅。
     * @access public
     */
    public function Post()
    {
        #获取数据
        $data=array
        (
            'CompanyName'=>Functions::FormArgs('Magazine_Index_CompanyName',200,TRUE),
            'Linkman'=>Functions::FormArgs('Magazine_Index_Linkman',200,TRUE),
            'PhoneNumber'=>Functions::FormArgs('Magazine_Index_Phone',200,TRUE),
            'Email'=>Functions::FormArgs('Magazine_Index_Email',200,TRUE),
            'Postcode'=>Functions::FormArgs('Magazine_Index_Postcode',200,TRUE),
            'Address'=>Functions::FormArgs('Magazine_Index_Address',200,TRUE)
        );

        #插入数据
        DB::Insert('dm_subscription',$data);
        echo 'Success';
    }
}
?>